import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

const BASE_URL = '/system/todo'

// export interface TodoResp {
//   id: string
//   title: string
//   content: string
//   priority: string
//   status: string
//   type: string
//   businessType: string
//   startTime: string
//   endTime: string
//   todoUsers: string
//   todoMethods: string
//   createUserString: string
//   updateUserString: string
//   disabled: boolean
// }
// export interface TodoDetailResp {
//   id: string
//   title: string
//   content: string
//   priority: string
//   status: string
//   type: string
//   businessType: string
//   startTime: string
//   endTime: string
//   todoScope: string
//   todoUsers: string
//   todoMethods: string
//   isRemind: string
//   remindTime: string
//   createUser: string
//   createTime: string
//   updateUser: string
//   updateTime: string
//   createUserString: string
//   updateUserString: string
// }
// export interface TodoQuery {
//   title: string | undefined
//   content: string | undefined
//   priority: string | undefined
//   status: string | undefined
//   type: string | undefined
//   businessType: string | undefined
//   startTime: string | undefined
//   endTime: string | undefined
//   todoScope: string | undefined
//   sort: Array<string>
// }

// export interface TodoPageQuery extends TodoQuery, PageQuery {
// }

/** @desc 查询待办事项列表 */
export function listTodo(query: TodoPageQuery) {
    return http.get<PageRes<TodoResp[]>>(BASE_URL, query)
}

/** @desc 查询待办事项详情 */
export function getTodo(id: string) {
    return http.get<TodoDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增待办事项 */
export function addTodo(data: any) {
    return http.post(BASE_URL, data)
}

/** @desc 修改待办事项 */
export function updateTodo(data: any, id: string) {
    return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除待办事项 */
export function deleteTodo(id: string) {
    return http.del(BASE_URL, {ids: [id]})
}

/** @desc 导出待办事项 */
export function exportTodo(query: TodoQuery) {
    return http.download(`${BASE_URL}/export`, query)
}

/** @desc 检查是否发起过申请 */
export function checkDodoStatus() {
    return http.get(`${BASE_URL}/check/withdrawal/requests`)
}
